<?php
// 生成一个PHP数组
$data = array();
$data['1'] = $_POST['1'];
$data['2'] = $_POST['2'];
$data['3'] = $_POST['3'];
$data['4'] = $_POST['4'];
 $data['5'] = $_POST['5'];
// 把PHP数组转成JSON字符串
$json_string = json_encode($data);
 
   $filename = 'install_sql.json';
   $fp= fopen($filename, "w");  //w是写入模式，文件不存在则创建文件写入。
   $len = fwrite($fp,$json_string);
   fclose($fp);
   echo $len .':JSON写入成功,请等待数据库创建！';
$link=mysqli_connect($data[1],$data[2],$data[3]);//链接数据库
$select=mysqli_select_db($link,$data[4]);//选择数据库
$sql = "CREATE TABLE `OurShareUserName` ( `username` CHAR(100) PRIMARY KEY , `password` TEXT NOT NULL , `vip` INT(100) NOT NULL ) ENGINE = MyISAM;";
$sql1 = "CREATE TABLE `OurShareAdminPass` ( `adminpass` CHAR(100) NOT NULL ) ENGINE = MyISAM;";
$sql2 = "CREATE TABLE `OurShareUrlSave` (`key1` int(11) PRIMARY KEY , `www` TEXT NOT NULL ) ENGINE = MyISAM;";
if (mysqli_query($link,$sql)) {
    echo "<br>表 OurShareUserName 创建成功";
} else {
    echo "<br>表 OurShareUserName 出现问题，请按照报错内容修改<br>";
    echo mysqli_error();
}
if (mysqli_query($link,$sql1)) {
    echo "<br>表 OurShareAdminPass 创建成功";
} else {
    echo "<br>表 OurShareAdminPass 出现问题，请按照报错内容修改<br>";
    echo mysqli_error();
}
if (mysqli_query($link,$sql2)) {
    echo "<br>表 OurShareUrlSave 创建成功";
} else {
    echo "<br>表 OurShareUrlSave 出现问题，请按照报错内容修改<br>";
    echo mysqli_error();
}
$sqlx="insert into `OurShareAdminPass` values("."\""."$data[5]"."\"".");";//将注册信息插入数据库表中
$sqly="insert into `OurShareUrlSave` values(10000,'wu');";//将注册信息插入数据库表中
        mysqli_query($link,$sqlx);
mysqli_query($link,$sqly);
$data1 = array();
$data1['1'] ="OK";
 
// 把PHP数组转成JSON字符串
$json_string1 = json_encode($data1);
 
   $filename1 = 'install_lock.json';
   $fp1= fopen($filename1, "w");  //w是写入模式，文件不存在则创建文件写入。
   $len1 = fwrite($fp1,$json_string1);
   fclose($fp1);
echo "<br>锁定安装成功，解锁请清空install_lock.json";
echo "<br>后台创建成功，后台地址".$_SERVER['HTTP_HOST']."/admin";
?>